/*!
 * PhotoSphereViewer.MapPlugin 5.4.4
 * @copyright 2023 Damien "Mistic" Sorel
 * @licence MIT (https://opensource.org/licenses/MIT)
 */

@use 'sass:math';
// *** MAIN ***
$psv-main-background-stops: #fff 0%,
    #fdfdfd 16%,
    #fbfbfb 33%,
    #f8f8f8 49%,
    #efefef 66%,
    #dfdfdf 82%,
    #bfbfbf 100% !default;
$psv-main-background: radial-gradient($psv-main-background-stops) !default;
$psv-element-focus-outline: 2px solid #007cff !default;

// *** LOADER ***
$psv-loader-bg-color: rgba(61, 61, 61, 0.5) !default;
$psv-loader-color: rgba(255, 255, 255, 0.7) !default;
$psv-loader-width: 150px !default;
$psv-loader-tickness: 10px !default;
$psv-loader-border: 3px !default;
$psv-loader-font: 600 16px sans-serif !default;

// *** NAVBAR ***
$psv-navbar-height: 40px !default;
$psv-navbar-background: rgba(61, 61, 61, 0.5) !default;

$psv-caption-font: 16px sans-serif !default;
$psv-caption-text-color: rgba(255, 255, 255, 0.7) !default;

$psv-buttons-height: 20px !default;
$psv-buttons-padding: (($psv-navbar-height - $psv-buttons-height) * 0.5) !default;
$psv-buttons-background: transparent !default;
$psv-buttons-active-background: rgba(255, 255, 255, 0.2) !default;
$psv-buttons-color: rgba(255, 255, 255, 0.7) !default;
$psv-buttons-disabled-opacity: 0.5 !default;

$psv-buttons-hover-scale: 1.2 !default;
$psv-buttons-hover-scale-delay: 200ms !default;

$psv-zoom-range-width: 80px !default;
$psv-zoom-range-tickness: 1px !default;
$psv-zoom-range-diameter: 7px !default;
$psv-zoom-range-media-min-width: 600px !default;

// *** TOOLTIP ***
$psv-tooltip-background: rgba(61, 61, 61, 0.8) !default;
$psv-tooltip-animate-offset: 5px !default;
$psv-tooltip-animate-delay: 100ms !default;
$psv-tooltip-radius: 4px !default;
$psv-tooltip-padding: 0.5em 1em !default;
$psv-tooltip-arrow-size: 7px !default;
$psv-tooltip-max-width: 200px !default;

$psv-tooltip-text-color: rgb(255, 255, 255) !default;
$psv-tooltip-font: 14px sans-serif !default;
$psv-tooltip-text-shadow: 0 1px #000 !default;

$psv-tooltip-shadow-color: rgba(90, 90, 90, 0.7) !default;
$psv-tooltip-shadow-offset: 3px !default; // the shadow is always at the opposite side of the arrow

// *** PANEL ***
$psv-panel-background: rgba(10, 10, 10, 0.7) !default;
$psv-panel-text-color: rgb(220, 220, 220) !default;
$psv-panel-font: 16px sans-serif !default;
$psv-panel-width: 400px !default;
$psv-panel-padding: 1em !default;
$psv-panel-animate-delay: 100ms !default;

$psv-panel-resizer-width: 9px !default; // must be odd
$psv-panel-resizer-background: rgba(0, 0, 0, 0.9) !default;
$psv-panel-resizer-grip-color: #fff !default;
$psv-panel-resizer-grip-height: 29px !default; // must be odd
$psv-panel-close-button-size: 32px !default;
$psv-panel-close-button-background: $psv-panel-resizer-background !default;
$psv-panel-close-button-color: #fff !default;
$psv-panel-close-button-animate-delay: 300ms !default;

$psv-panel-title-font: 24px sans-serif !default;
$psv-panel-title-icon-size: 24px !default;
$psv-panel-title-margin: 24px !default;

$psv-panel-menu-item-height: 1.5em !default;
$psv-panel-menu-item-padding: 0.5em 1em !default;
$psv-panel-menu-item-active-outline: 1px !default;
$psv-panel-menu-odd-background: rgba(255, 255, 255, 0.1) !default;
$psv-panel-menu-even-background: transparent !default;
$psv-panel-menu-hover-background: rgba(255, 255, 255, 0.2) !default;

// *** NOTIFICATION ***
$psv-notification-position-from: -$psv-navbar-height !default;
$psv-notification-position-to: $psv-navbar-height * 2 !default;
$psv-notification-animate-delay: 200ms !default;
$psv-notification-background: $psv-tooltip-background !default;
$psv-notification-radius: $psv-tooltip-radius !default;
$psv-notification-padding: $psv-tooltip-padding !default;
$psv-notification-font: $psv-tooltip-font !default;
$psv-notification-text-color: $psv-tooltip-text-color !default;

// *** OVERLAY ***
$psv-overlay-opacity: 0.8 !default;
$psv-overlay-title-font: 30px sans-serif !default;
$psv-overlay-title-color: black !default;
$psv-overlay-text-font: 20px sans-serif !default;
$psv-overlay-text-color: rgba(0, 0, 0, 0.8) !default;
$psv-overlay-image-size: (
    portrait: 50vw,
    landscape: 25vw,
) !default;

// *** Z-INDEXES ***
$psv-canvas-zindex: 0 !default;
$psv-hud-zindex: 10 !default;
$psv-polygon-marker-zindex: 20 !default;
$psv-marker-zindex: 30 !default;
$psv-compass-zindex: 40 !default;
$psv-tooltip-zindex: 50 !default;
$psv-loader-zindex: 80 !default;
$psv-panel-zindex: 90 !default;
$psv-navbar-zindex: 90 !default;
$psv-notification-zindex: 100 !default;
$psv-overlay-zindex: 110 !default;


$psv-map-margin: 10px !default;
$psv-map-background: rgba(61, 61, 61, 0.7) !default;
$psv-map-toolbar-font: 12px sans-serif !default;
$psv-map-toolbar-background: #222 !default;
$psv-map-toolbar-text-color: white !default;
$psv-map-button-size: 34px !default;
$psv-map-button-spacing: 3px !default;
$psv-map-button-color: $psv-buttons-color !default;
$psv-map-transition: ease-in-out 0.3s !default;

@function round-to($value, $precision) {
    @return math.div(math.round($value * $precision), $precision);
}

.psv-container {
    --psv-map-plugin-loaded: true;
}

.psv-map {
    position: absolute;
    margin: $psv-map-margin;
    z-index: $psv-compass-zindex;
    transition: all $psv-map-transition;

    @at-root .psv--has-navbar & {
        margin-bottom: calc(#{$psv-navbar-height} + #{$psv-map-margin});
    }

    &__container {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: -1;
        background: $psv-map-background;
        overflow: hidden;
        border-radius: 50%;
        transition: all $psv-map-transition;

        svg,
        img,
        canvas {
            width: 100%;
            height: 100%;
        }
    }

    &__overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
    }

    &__toolbar {
        position: absolute;
        bottom: 1em;
        left: calc(50% - 3.25em); // (padding * 2 + icon * 2 + text) / 2
        display: flex;
        justify-content: center;
        align-items: center;
        font: $psv-map-toolbar-font;
        padding: 0.25em;
        border-radius: 1.5em;
        background: $psv-map-toolbar-background;
        color: $psv-map-toolbar-text-color;
        user-select: none;
        transition: opacity $psv-map-transition;

        svg {
            height: 1em;
            cursor: pointer;
        }

        &-text {
            width: 4em;
            text-align: center;
        }
    }

    &__button {
        position: absolute;
        width: $psv-map-button-size;
        aspect-ratio: 1;
        line-height: 0;
        background: $psv-map-background;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        transform-origin: center;
        color: $psv-map-button-color;
        cursor: pointer;
        transition: all $psv-map-transition;

        svg {
            width: 60%;
        }

        // "sigh"
        $button-position: #{round-to((1 - math.cos(45deg)) * 50%, 1000)};
        /* stylelint-disable max-line-length */
        $button-offset: #{$psv-map-button-size - round-to((1 - math.cos(45deg)) * $psv-map-button-size * 0.5, 1000) + $psv-map-button-spacing};
        /* stylelint-enable */

        &--top-left {
            left: $button-position;
            top: $button-position;
            transform: translate(-$button-offset, -$button-offset);
        }

        &--top-right {
            right: $button-position;
            top: $button-position;
            transform: translate($button-offset, -$button-offset);
        }

        &--bottom-left {
            left: $button-position;
            bottom: $button-position;
            transform: translate(-$button-offset, $button-offset);
        }

        &--bottom-right {
            right: $button-position;
            bottom: $button-position;
            transform: translate($button-offset, $button-offset);
        }
    }

    &--maximized {
        margin: 0;
        width: 100% !important;
        height: 100% !important;

        @at-root .psv--has-navbar & {
            height: calc(100% - #{$psv-navbar-height}) !important;
            margin-bottom: $psv-navbar-height;
        }
    }

    &--maximized &__container {
        border-radius: 0;
    }

    &--maximized &__button {
        border: 2px solid currentcolor;

        &--top-left {
            left: $psv-map-button-size + $psv-map-margin;
            top: $psv-map-button-size + $psv-map-margin;
        }

        &--top-right {
            right: $psv-map-button-size + $psv-map-margin;
            top: $psv-map-button-size + $psv-map-margin;
        }

        &--bottom-left {
            left: $psv-map-button-size + $psv-map-margin;
            bottom: $psv-map-button-size + $psv-map-margin;
        }

        &--bottom-right {
            right: $psv-map-button-size + $psv-map-margin;
            bottom: $psv-map-button-size + $psv-map-margin;
        }
    }

    &--collapsed {
        width: $psv-map-button-size !important;
        height: $psv-map-button-size !important;

        & > * {
            opacity: 0;
        }
    }

    &--collapsed &__button-close {
        opacity: 1;
        transform: translate(0, 0);
        z-index: 1;
    }

    &--top-left {
        top: 0;
        left: 0;
    }

    &--top-right {
        top: 0;
        right: 0;
    }

    &--bottom-left {
        bottom: 0;
        left: 0;
    }

    &--bottom-right {
        bottom: 0;
        right: 0;
    }
}
